package com.ck.print.demo.printbridge;

import cn.hutool.core.lang.UUID;
import com.ck.print.demo.printbridge.message.qzcmd.PrinterListenCmd;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URISyntaxException;
import java.util.concurrent.ScheduledExecutorService;

public class QzTrayWebSocketClient extends PrintWebSocketClient {
    public QzTrayWebSocketClient(String serverUri, String clientInfo, ScheduledExecutorService scheduler) throws URISyntaxException {
        super(serverUri, clientInfo, scheduler);
    }

    /**
     * 连接建立成功需要想所有的打印机发送监听指令
     *
     * @param handshakedata The handshake of the websocket instance
     */
    @Override
    public void onOpen(ServerHandshake handshakedata) {
        super.onOpen(handshakedata);
        PrinterListenCmd cmd = new PrinterListenCmd(UUID.randomUUID().toString(Boolean.TRUE));
        this.send(gson.toJson(cmd));
    }


}
